package chaw.android.train.MoreActivities;

import chaw.android.train.MoreActivity;
import chaw.android.train.R;
import chaw.android.train.TrainTravelActivity;
import chaw.android.util.Preferences;
import chaw.android.util.ServerURL;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;

public class MoreSpecialActivity extends Activity {
	private WebView moreAnnounceWebView;
	private WebViewClient client;
	private ImageView backBtn;
	
	@Override
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
        setContentView(R.layout.more_special);
		
        backBtn = (ImageView) findViewById(R.id.backBtn);
        backBtn.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				MoreActivity parentActivity = (MoreActivity)getParent();
				parentActivity.finishFromChild(MoreSpecialActivity.this);
			}
		});
        
        moreAnnounceWebView = (WebView) findViewById(R.id.moreAnnounceWebView);
        client = new WebViewClient();
        String device_token = Preferences.getValue(getBaseContext(), "registration");
        String user_id = Preferences.getValue(getBaseContext(), "user_id");
        String version = Preferences.getValue(getBaseContext(), "version");
		String url = ServerURL.moreSpecialWebView + "?device_token=" + device_token + "user_id=" + user_id + "version=" + version;
		moreAnnounceWebView.setWebViewClient(client);
		moreAnnounceWebView.loadUrl(url);
		moreAnnounceWebView.getSettings().setJavaScriptEnabled(true);
	}
	
	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		for(int i = 0 ; i < 5; i++)
        	TrainTravelActivity.tabHost.getTabWidget().getChildAt(i).setBackgroundResource(R.drawable.bg_nav1);
	}
}
